package cn.gok.server.controller;

import cn.gok.common.config.SystemLog;
import cn.gok.common.resp.Result;
import cn.gok.common.entity.backstage.SysMenu;
import cn.gok.server.service.SysMenuService;
import cn.gok.utils.ResultUtil;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author: DxlinY
 * @apiNote: 菜单相关接口
 * @date: 2020/9/26
 * @time: 15:19
 */
@RestController
@RequestMapping("server")
public class SysMenuController {


    @Resource(name = "sysMenuServiceImpl")
    private SysMenuService sysMenuService;

    /**
     * 用户获取菜单数据
     *
     * @return
     */
    @RequestMapping(value = "menu", method = RequestMethod.POST)
    @SystemLog(model = "后台管理系统菜单", method = "获取用户菜单")
    public Result listMenusById() {
        List <SysMenu> sysMenus = sysMenuService.getMenus();
        if (!sysMenus.isEmpty()) {
            return ResultUtil.success(sysMenus);
        }
        return ResultUtil.dataNotFound();
    }
}
